<%@page import="com.iris.egrant.service.ServiceUtils"%>
<%@page import="java.net.URLEncoder"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<x:parse xml="${param.xmlstr}" var="xmlData" />

<div class="t_bar">
	申请人已取得成果目录
</div>
<table  id="tblExecuteProducts" cellpadding="0" class="table01" width="100%" border="0" cellpadding="0">
		<thead>
		<tr>
			<th class="TblHead" align="center" width="5%"  >选择</th>
			<th class="TblHead" align="center" width="5%"  >序号</th>
			<th class="TblHead" align="center" width="10%">中文标题</th>
			<th class="TblHead" align="center" width="10%">英文标题</th>
			<th class="TblHead" align="center" width="10%">成果类型</th>

			<th class="TblHead" align="center" width="5%">完成人</th>
			<th class="TblHead" align="center" width="10%">申请人排位</th>
			<th class="TblHead" align="center" width="10%">成果日期</th>
			<th class="TblHead" align="center" width='5%'>备注</th>
			<th class="TblHead" align="center" width="15%">SCI/EI 收录情况</th>
			<th class="TblHead" align="center" width="10%">他人引用次数</th>
			<th class="TblHead" align="center" width="5%" >操作</th>
			</tr>
		</thead>
	<tbody>
	<tr style="display: none">
 		<td  >
 			<input type="radio" class="radiobutton" name="selExecuteProducts" onclick="setProductsRule('tblExecuteProducts','selExecuteProducts');"/>
 			<input type="hidden" name="products|product[0]|product_type" value=""/>
 			<input type="hidden" name="products|product[0]|xmldata" value=""/>
 			<input type="hidden" name="products|product[0]|category_id" value=""/>
 			<input type="hidden" name="products|product[0]|lianjie" value=""/>
 			<input type="hidden" name="products|product[0]|bj_jigou" value=""/>
 			<input type="hidden" name="products|product[0]|country" value=""/>
 			<input type="hidden" name="products|product[0]|miaosu" value=""/>
 			<input type="hidden" name="products|product[0]|keywords" value=""/>
 			<input type="hidden" name="products|product[0]|jl_dengji" value=""/>
 			<input type="hidden" name="products|product[0]|btype_value" value=""/>
 			<input type="hidden" name="products|product[0]|btype_value_name" value=""/>
 			<input type="hidden" name="products|product[0]|press" value=""/>
 			<input type="hidden" name="products|product[0]|isbn" value=""/>
 			<input type="hidden" name="products|product[0]|pages" value=""/>
 			<input type="hidden" name="products|product[0]|twords" value=""/>
 			<input type="hidden" name="products|product[0]|bname" value=""/>
 			<input type="hidden" name="products|product[0]|seriesname" value=""/>
 			<input type="hidden" name="products|product[0]|editor" value=""/>
 			<input type="hidden" name="products|product[0]|chaptersnum" value=""/>
 			<input type="hidden" name="products|product[0]|page1" value=""/>
 			<input type="hidden" name="products|product[0]|page2" value=""/>
 			<input type="hidden" name="products|product[0]|city" value=""/>
 			<input type="hidden" name="products|product[0]|conferencename" value=""/>
 			<input type="hidden" name="products|product[0]|conferenceman" value=""/>
 			<input type="hidden" name="products|product[0]|cs_date" value=""/>
 			<input type="hidden" name="products|product[0]|ce_date" value=""/>
 			<input type="hidden" name="products|product[0]|ctype_value" value=""/>
 			<input type="hidden" name="products|product[0]|ctype_value_name" value=""/>
 			<input type="hidden" name="products|product[0]|record_status" value=""/>
 			<input type="hidden" name="products|product[0]|volume" value=""/>
 			<input type="hidden" name="products|product[0]|term" value=""/>
 			<input type="hidden" name="products|product[0]|dept" value=""/>
 			
 			<input type="hidden" name="products|product[0]|en_miaosu" value=""/>
 			<input type="hidden" name="products|product[0]|en_keywords" value=""/>
 			<input type="hidden" name="products|product[0]|js_date" value=""/>
 		</td>
 		<td  >
 			&nbsp;
 			<span name="products|product[0]@seq_no" >[index]</span>
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|tname" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|en_tname" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|product_type_name" />
 		</td>
 		
 		<td>
 			&nbsp;
 			<span name="products|product[0]|psn_name" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|paiwei" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|cg_date" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|remark" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|identify_name" />
 		</td>
 		<td>
 			&nbsp;
 			<span name="products|product[0]|yinyong_num" />
 		</td>
 		<td>
 		<a href="#" onclick="ViewProductDetail(this)">查看</a>
 		</td>
 	</tr>


		<c:set value="0" var="index" scope="page" />
		<x:forEach select="$xmlData/data/products/product" var="pro">
		
				
				<c:choose>
					<c:when test="${index<10}">
						<c:set value="0" var="flag" scope="page" />
					</c:when>
					<c:otherwise>
						<c:set value="" var="flag" scope="page" />
					</c:otherwise>
				</c:choose>
				<tr>
					<td  >
				<input type="radio" class="radiobutton" name="selExecuteProducts" onclick="setProductsRule('tblExecuteProducts','selExecuteProducts');"/>
				<input type="hidden" name="products/product[${flag}${index}]/product_type" value="<x:out select="$pro/product_type"/>"/>
				<input type="hidden" name="products/product[${flag}${index}]/xmldata" value="<x:out select="$pro/xmldata"/>"/>
				<input type="hidden" name="products/product[${flag}${index}]/category_id" value="<x:out select="$pro/category_id"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/lianjie" value="<x:out select="$pro/lianjie"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/bj_jigou" value="<x:out select="$pro/bj_jigou"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/country" value="<x:out select="$pro/country"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/miaosu" value="<x:out select="$pro/miaosu"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/keywords" value="<x:out select="$pro/keywords"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/jl_dengji" value="<x:out select="$pro/jl_dengji"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/btype_value" value="<x:out select="$pro/btype_value"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/btype_value_name" value="<x:out select="$pro/btype_value_name"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/press" value="<x:out select="$pro/press"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/isbn" value="<x:out select="$pro/isbn"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/pages" value="<x:out select="$pro/pages"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/twords" value="<x:out select="$pro/twords"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/bname" value="<x:out select="$pro/bname"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/seriesname" value="<x:out select="$pro/seriesname"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/editor" value="<x:out select="$pro/editor"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/chaptersnum" value="<x:out select="$pro/chaptersnum"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/page1" value="<x:out select="$pro/page1"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/page2" value="<x:out select="$pro/page2"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/city" value="<x:out select="$pro/city"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/conferencename" value="<x:out select="$pro/conferencename"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/conferenceman" value="<x:out select="$pro/conferenceman"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/cs_date" value="<x:out select="$pro/cs_date"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/ce_date" value="<x:out select="$pro/ce_date"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/ctype_value" value="<x:out select="$pro/ctype_value"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/ctype_value_name" value="<x:out select="$pro/ctype_value_name"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/record_status" value="<x:out select="$pro/record_status"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/volume" value="<x:out select="$pro/volume"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/term" value="<x:out select="$pro/term"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/dept" value="<x:out select="$pro/dept"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/en_miaosu" value="<x:out select="$pro/en_miaosu"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/en_keywords" value="<x:out select="$pro/en_keywords"/>"/>
 				<input type="hidden" name="products/product[${flag}${index}]/js_date" value="<x:out select="$pro/js_date"/>"/>
 				
 			</td>
					<td  >
 				&nbsp;
 				<span name="products/product[${flag}${index}]@seq_no">${index+1}</span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/tname"><x:out select="$pro/tname" /></span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/en_tname"><x:out select="$pro/en_tname" /></span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/product_type_name"><x:out select="$pro/product_type_name" /></span>
 			</td>
 			
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/psn_name"><x:out select="$pro/psn_name" /> </span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/paiwei"><x:out select="$pro/paiwei" /> </span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/cg_date"><x:out select="$pro/cg_date" /> </span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/remark"><x:out select="$pro/remark" /> </span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/identify_name"><x:out select="$pro/identify_name" /> </span>
 			</td>
 			<td>
 				&nbsp;
 				<span name="products/product[${flag}${index}]/yinyong_num"><x:out select="$pro/yinyong_num" /> </span>
 			</td>
 			<td>
 				<a href="#" onclick="ViewProductDetail(this)">查看</a>
 			</td>
				</tr>
				<c:set value="${index+1}" var="index" scope="page" />
		</x:forEach>
	</tbody>
					</table>
					<br>

					<input type="hidden" id="current_protype" name="current_protype" value=""/>
					<input type="hidden" id="current_protype_name" name="current_protype_name" value=""/>
					<input type="hidden" id="current_protype_page" name="current_protype_page" value=""/>
	<table width="100%"   align="center"  >
	<tr><td>
		<input class="button" name="cmdAddbefore" id="cmdAddbeforeProduct" type="button" value="添加" onclick="addRow('ResultMain?flag=add');setProductsRule('tblExecuteProducts','selExecuteProducts');try{top.resizeFrame();}catch(e){};"/>
		<input class="button" name="cmdMovePrev" id="cmdMovePrevProduct" type="button" value="上移" onclick="movePrev('tblExecuteProducts','selExecuteProducts');setProductsRule('tblExecuteProducts','selExecuteProducts');"/>
		<input class="button" name="cmdMoveNext" id="cmdMoveNextProduct" type="button" value="下移" onclick="moveNext('tblExecuteProducts','selExecuteProducts');setProductsRule('tblExecuteProducts','selExecuteProducts')"/>
		<input class="button" name="cmdEdit" id="cmdEditProduct" type="button" value="编辑" onclick="updateProduct();"/>
		<input class="button" name="cmddel" id="cmddelProduct" type="button" value="删除" onclick="deleteSelectedRow('tblExecuteProducts','成果')"/>
	</td></tr>
	</table>

	

<script type="text/javascript">


		function addRow(url)
		{
			sourceXML = "<data></data>";
			addNewRow('tblExecuteProducts',"${ctx}/proposal/edit/PrpResult/"+url+"&xmlData="+encodeURIComponent(encodeURIComponent(xmlEncrypt(sourceXML)))+"&product_type="+document.getElementById("current_protype").value+"&product_type_name="+encodeURIComponent(document.getElementById("current_protype_name").value)+"&TB_iframe=true&width=850",'增加');
			try{top.resizeFrame();}catch(e){};
		}


		function updateProduct()
		{   
			var selectedRow=getSelectedRow("selExecuteProducts");
			var xmldata = $(selectedRow).find("input[name$='xmldata']").val();
			var product_type = $(selectedRow).find("input[name$='product_type']").val();
			if(xmldata=="")
				xmldata="<data></data>";
			var url = getUpdatePage(product_type);
			if(url == ""){
				return ;
			}
			
			var url = "ResultMain?flag=edit&xmlData="+encodeURIComponent(encodeURIComponent(xmlEncrypt(xmldata)))+"&product_type="+product_type+"&targetURL="+url;
			if (selectedRow==null)return false;
			if(url=="") return false;
			editRow('tblExecuteProducts',"${ctx}/proposal/edit/PrpResult/"+url+"&TB_iframe=true&width=850",'更新');
		}
		function ViewProductDetail(obj)
		{
			var radioname="selExecuteProducts";
			var tr=obj.parentElement.parentElement;
			allObj = tr.getElementsByTagName("*");
			for(var j = 0; j < allObj.length; j++)
			{
			   if(allObj[j].name) 
			   {
			   		strName = allObj[j].name;
			   		if(strName==radioname) 
			   		{
			   			allObj[j].checked=true;
			   			break;
			   		}
			   	}
			}
			var selectedRow=tr;
			var xmldata = $(selectedRow).find("input[name$='xmldata']").val();
			var product_type = $(selectedRow).find("input[name$='product_type']").val();
			if(xmldata=="")xmldata="<data></data>";
			var url = getUpdatePage(product_type);
			if(url == ""){
				return ;
			}
			var url = "ResultMain?flag=view&xmlData="+encodeURIComponent(encodeURIComponent(xmlEncrypt(xmldata)))+"&product_type="+product_type+"&targetURL="+url;
			if (selectedRow==null)		
				return false;
			if(url=="") return false;
			viewRow('tblExecuteProducts',"${ctx}/proposal/edit/PrpResult/"+url+"&TB_iframe=true&width=850",'查看');
		}
			function getUpdatePage(no){
				var iNo;
				var str;
				iNo = parseInt(no);
				if(iNo){
					switch(iNo){
						case 1:str = "PrizeEdit";break;
						case 2:str = "BookEdit";break;
						case 3:str = "LiteratureEdit";break;
						case 4:str = "TreatiseEdit";break;
						case 5:str = "JournalEdit";break;
						case 6:str = "PatentsEdit";break;
						case 7:str = "DissertationEdit";break;
						case 8:str = "OtherEdit";break;
				}
				return str;
			}
			return "";
		}
			
		function getSelectedRow(radioname)
			{
				var selectedRadio = $("input[name="+radioname+"]:checked").get(0);
				if (selectedRadio==null)
				{
					alert("请先选择一条记录！");
					return null;
				}
				var tr=$(selectedRadio).parents("tr").get(0);
				return tr;
				
			}
			
		/**
		* 打开页面查看内容
		* @param tableId 表格id
		* @param startRowIndex 起始行
		* @param url 跳转url
		* @param selObj 没有选中行,就指当前对象所在行
		*/
		function viewRow(tableId,url,title,selObj)
		{
			if(selObj)
			{
				
			}
			if(url!=null&&url!=""){
				showThickBox(url,title);	
			}
		}
			function setProductsRule(tblid,radioname)
			{
				/*
				var tbl = document.getElementById(tblid);
				var obj = null;
				var seq_no = 0;
				var nRowCnt=tbl.rows.length;
				var selectedRow = getSelectedRow(radioname,true);
				
				if (selectedRow == null)
					seq_no = 0;
				else
					seq_no = selectedRow.rowIndex-1;
				
				objAdd = document.getElementById("cmdAddbeforeProduct");
				objAdd.disabled = false;
				
				objMpre = document.getElementById("cmdMovePrevProduct");
				objMpre.disabled = false;

				objMnxt = document.getElementById("cmdMoveNextProduct");
				objMnxt.disabled = false;
				
				objEdit = document.getElementById("cmdEditProduct");
				objEdit.disabled = false;
				
				objDel = document.getElementById("cmddelProduct");
				objDel.disabled = false;
				
				if(seq_no=="1")
				{
					objMpre.disabled = true;
				}
				else if(parseInt(seq_no) == parseInt(nRowCnt)-2)
				{
					objMnxt.disabled = true;
				}
				//document.getElementById("sel_protype").value = tbl.rows[selectedRow.rowIndex].children[0].childNodes[2].value;
				//document.getElementById("sel_protype_name").value = tbl.rows[selectedRow.rowIndex].children[0].childNodes[4].value;
				
				var selObjs = document.getElementsByName("protype");
				for(var i = 0;i<selObjs.length;i++)
				{
					if(selObjs[i].checked)
					{
						selObjs[i].checked = false;
						document.getElementById("current_protype").value='';
						document.getElementById("current_protype_name").value='';
						break;
					}
				}
				*/
			}
			
			function xmlEncrypt(strXmlData)
			{

				var xmlHttpRequest;
			   if(window.ActiveXObject)  //IE和其他的浏览器实现XMLHttpRequest的方式不同

			   {                   
				  xmlHttpRequest = new ActiveXObject("Microsoft.XMLHTTP");
			   }
			   else
			   {
				  xmlHttpRequest = new XMLHttpRequest();
			   }
			   
				var url = ctx+'/ajax/ajaxEncrypt';
				xmlHttpRequest.open('POST',url,false);
				xmlHttpRequest.setRequestHeader("Content-Type",   "application/x-www-form-urlencoded");   
				xmlHttpRequest.send("&xmldata="+encodeURIComponent(strXmlData));
				return xmlHttpRequest.responseText;
				
			}
</script>